/*
 * QryOpti.h
 *
 *  Created on: 09-Jan-2010
 *      Author: pankaj
 */

#ifndef QRYOPTI_H_
#define QRYOPTI_H_

#include "../Page.h"
#include <vector>

#define ASCENDING 0
#define DESECDING 1

using namespace std;

class QryOpti {

private:

	vector<unsigned char*> _keyformat;
	int _noskeyarg;
	vector<int> _sortorder;
	int _order;
	int _reclen;
	int _nosrec;

	void quicksort(int a, int b, vector<unsigned char*> &A);

	int compare(unsigned char* rec1, unsigned char* rec2);

	void copy(unsigned char* srec, unsigned char* drec);

	int internalSort(Page pag);
public:

	/*
	 * keyformat: keytype,length(for char & varchar),offset
	 * sortorder : which columns are required to be sorted according to order
	 */
	int sort(vector<int> inpagno, vector<unsigned char*> keyformat,
			int noskeyarg, vector<int> sortorder, int order, int reclen,
			vector<int> &outpagno);

	QryOpti();
	virtual ~QryOpti();
};

#endif /* QRYOPTI_H_ */
